package com.entites;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

@Entity
@Table(name = "Admin")
@XmlRootElement
@NamedQueries(
{
    @NamedQuery(name = "Admin.findAll", query = "SELECT a FROM Admin a"),
    @NamedQuery(name = "Admin.findByUsername", query = "SELECT a FROM Admin a WHERE a.username = :username"),
    @NamedQuery(name = "Admin.findByPassword", query = "SELECT a FROM Admin a WHERE a.password = :password"),
    @NamedQuery(name = "Admin.findByEmail", query = "SELECT a FROM Admin a WHERE a.email = :email"),
    @NamedQuery(name = "Admin.findByFullname", query = "SELECT a FROM Admin a WHERE a.fullname = :fullname"),
    @NamedQuery(name = "Admin.findByGender", query = "SELECT a FROM Admin a WHERE a.gender = :gender"),
    @NamedQuery(name = "Admin.findByBirthdate", query = "SELECT a FROM Admin a WHERE a.birthdate = :birthdate"),
    @NamedQuery(name = "Admin.findByPhone", query = "SELECT a FROM Admin a WHERE a.phone = :phone"),
    @NamedQuery(name = "Admin.findByMobilephone", query = "SELECT a FROM Admin a WHERE a.mobilephone = :mobilephone"),
    @NamedQuery(name = "Admin.findByAddress", query = "SELECT a FROM Admin a WHERE a.address = :address"),
    @NamedQuery(name = "Admin.findByIdentityCard", query = "SELECT a FROM Admin a WHERE a.identityCard = :identityCard"),
    @NamedQuery(name = "Admin.findByJoinInDate", query = "SELECT a FROM Admin a WHERE a.joinInDate = :joinInDate"),
    @NamedQuery(name = "Admin.findByPosition", query = "SELECT a FROM Admin a WHERE a.position = :position"),
    @NamedQuery(name = "Admin.findByDepartments", query = "SELECT a FROM Admin a WHERE a.departments = :departments"),
    @NamedQuery(name = "Admin.findByGroups", query = "SELECT a FROM Admin a WHERE a.groups = :groups"),
    @NamedQuery(name = "Admin.findByStatus", query = "SELECT a FROM Admin a WHERE a.status = :status"),
    @NamedQuery(name = "Admin.findByOnline", query = "SELECT a FROM Admin a WHERE a.online = :online"),
    @NamedQuery(name = "Admin.findByLogged", query = "SELECT a FROM Admin a WHERE a.logged = :logged")
})
public class Admin implements Serializable
{
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "Username")
    private String username;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "Password")
    private String password;
    // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "Email")
    private String email;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "Fullname")
    private String fullname;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "Gender")
    private String gender;
    @Basic(optional = false)
    @NotNull
    @Column(name = "Birthdate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date birthdate;
    // @Pattern(regexp="^\\(?(\\d{3})\\)?[- ]?(\\d{3})[- ]?(\\d{4})$", message="Invalid phone/fax format, should be as xxx-xxx-xxxx")//if the field contains phone or fax number consider using this annotation to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "Phone")
    private String phone;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "Mobilephone")
    private String mobilephone;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "Address")
    private String address;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "IdentityCard")
    private String identityCard;
    @Column(name = "JoinInDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date joinInDate;
    @Size(max = 100)
    @Column(name = "Position")
    private String position;
    @Size(max = 100)
    @Column(name = "Departments")
    private String departments;
    @Size(max = 200)
    @Column(name = "Groups")
    private String groups;
    @Size(max = 20)
    @Column(name = "Status")
    private String status;
    @Column(name = "Online")
    private Boolean online;
    @Column(name = "Logged")
    @Temporal(TemporalType.TIMESTAMP)
    private Date logged;

    public Admin()
    {
    }

    public Admin(String username)
    {
        this.username = username;
    }

    public Admin(String username, String password, String email, String fullname, String gender, Date birthdate, String phone, String mobilephone, String address, String identityCard)
    {
        this.username = username;
        this.password = password;
        this.email = email;
        this.fullname = fullname;
        this.gender = gender;
        this.birthdate = birthdate;
        this.phone = phone;
        this.mobilephone = mobilephone;
        this.address = address;
        this.identityCard = identityCard;
    }

    public String getUsername()
    {
        return username;
    }

    public void setUsername(String username)
    {
        this.username = username;
    }

    public String getPassword()
    {
        return password;
    }

    public void setPassword(String password)
    {
        this.password = password;
    }

    public String getEmail()
    {
        return email;
    }

    public void setEmail(String email)
    {
        this.email = email;
    }

    public String getFullname()
    {
        return fullname;
    }

    public void setFullname(String fullname)
    {
        this.fullname = fullname;
    }

    public String getGender()
    {
        return gender;
    }

    public void setGender(String gender)
    {
        this.gender = gender;
    }

    public Date getBirthdate()
    {
        return birthdate;
    }

    public void setBirthdate(Date birthdate)
    {
        this.birthdate = birthdate;
    }

    public String getPhone()
    {
        return phone;
    }

    public void setPhone(String phone)
    {
        this.phone = phone;
    }

    public String getMobilephone()
    {
        return mobilephone;
    }

    public void setMobilephone(String mobilephone)
    {
        this.mobilephone = mobilephone;
    }

    public String getAddress()
    {
        return address;
    }

    public void setAddress(String address)
    {
        this.address = address;
    }

    public String getIdentityCard()
    {
        return identityCard;
    }

    public void setIdentityCard(String identityCard)
    {
        this.identityCard = identityCard;
    }

    public Date getJoinInDate()
    {
        return joinInDate;
    }

    public void setJoinInDate(Date joinInDate)
    {
        this.joinInDate = joinInDate;
    }

    public String getPosition()
    {
        return position;
    }

    public void setPosition(String position)
    {
        this.position = position;
    }

    public String getDepartments()
    {
        return departments;
    }

    public void setDepartments(String departments)
    {
        this.departments = departments;
    }

    public String getGroups()
    {
        return groups;
    }

    public void setGroups(String groups)
    {
        this.groups = groups;
    }

    public String getStatus()
    {
        return status;
    }

    public void setStatus(String status)
    {
        this.status = status;
    }

    public Boolean getOnline()
    {
        return online;
    }

    public void setOnline(Boolean online)
    {
        this.online = online;
    }

    public Date getLogged()
    {
        return logged;
    }

    public void setLogged(Date logged)
    {
        this.logged = logged;
    }

    @Override
    public int hashCode()
    {
        int hash = 0;
        hash += (username != null ? username.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object)
    {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Admin))
        {
            return false;
        }
        Admin other = (Admin) object;
        if ((this.username == null && other.username != null) || (this.username != null && !this.username.equals(other.username)))
        {
            return false;
        }
        return true;
    }

    @Override
    public String toString()
    {
        return "com.entites.Admin[ username=" + username + " ]";
    }

}
